<template>
    <div class="app-container">
    修改竞赛信息
    <el-form label-width="120px">
        <el-form-item label="竞赛名称">
            <el-input v-model="com.cname"/>
        </el-form-item>

        <el-form-item label="年度">
            <el-input v-model="com.year"/>
        </el-form-item>

        <el-form-item label="竞赛内容">
            <el-input v-model="com.content"/>
        </el-form-item>

        <el-form-item label="竞赛日期">
            <el-input v-model="com.date"/>
        </el-form-item>

        <el-form-item label="竞赛规范">
            <el-input v-model="com.norm"/>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="update">修改</el-button>
        </el-form-item>

        </el-form>
    </div>
</template>

<script>
import admin from '@/api/admin' 

export default {
    data() {
        return {
            com:{},
        }
    },
    created(){
        const routeParams=this.$route.params;
        if(routeParams && routeParams.id){
            //得到路由参数（id）的值
            const id=routeParams.id;
            this.getCom(id)
        }
        
    },
    methods:{
        getCom(id){
            admin.getCom(id).then(response=>{
                this.com= response.data;
            })
        },
        //修改医院设置
        update(){
            admin.updatedCom(this.com).then(response=>{
                //提示
                this.$message({
                    type:'success',
                    message:'修改成功'
                })
                //跳转列表页面 使用路由跳转方式实现
                this.$router.push({path:'/admin/list'})
            }) 
        },
        
    }
}
</script>

<style>

</style>